﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Rabbit.Domain;
using Rabbit.DTO.Input;
using Rabbit.Service;

namespace Rabbit.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class GoodsController : ControllerBase
    {
        GoodsService res;

        public GoodsController(GoodsService res)
        {
            this.res = res;
        }


        /// <summary>
        /// 商品显示
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetGoods()
        {
            return Ok(res.GetGoods());
        }
        /// <summary>
        /// 添加商品
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult AddGoods(GoodsInput input)
        {
            return Ok(res.AddGoods(input));
        }

        /// <summary>
        /// 逻辑删
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="names"></param>
        /// <returns></returns>
        [HttpDelete]
        public IActionResult DelGoods(string ids, string names)
        {
            return Ok(res.DelGoods(ids, names));
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult UpdGoods(Goods entity)
        {
            return Ok(res.UpdGoods(entity));
        }

        /// <summary>
        /// 商品显示
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetGoodsxlk()
        {
            return Ok(res.GetGoodsxlk());
        }



    }
}
